package cn.com.xf.dao.impl;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import cn.com.xf.dao.TbsecuritycheckDao;
import cn.com.xf.dao.support.XFSqlMapClientDaoSupport;
import cn.com.xf.domain.Tbsecuritycheck;
@Repository
public class TbsecuritycheckDaoImpl extends XFSqlMapClientDaoSupport implements TbsecuritycheckDao {
	@Override
	public int insertBatch(List<Tbsecuritycheck> list) {
		int count = 0;
		try {
			// 自己控制事物的开始
			getSqlMapClient().startTransaction();
			getSqlMapClient().startBatch();
			for (Tbsecuritycheck data : list) {
				try {
					getSqlMapClientTemplate().insert("TBSECURITYCHECK.ibatorgenerated_insertSelective", data);
					count = getSqlMapClient().executeBatch();
					getSqlMapClient().commitTransaction();
				} catch (SQLException e) {
				}
			}

		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			// 自己控制事物的结束
			try {
				getSqlMapClient().endTransaction();
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return count;
	}

	@Override
	public int selectCount(String scandate, String scanclass,String entersite) {
		Map<String ,Object> map = new HashMap<String,Object>();
		map.put("scandate",scandate);
		map.put("scanclass", scanclass);
		map.put("entersite", entersite);
		return (Integer)getSqlMapClientTemplate().queryForObject("TBSECURITYCHECK.selectCount",map);
	}

	@Override
	public void insert(Tbsecuritycheck tb) {
		getSqlMapClientTemplate().insert("TBSECURITYCHECK.ibatorgenerated_insert", tb);
	}
}
